//
//  GifCell.m
//  ToYourHeartNews
//
//  Created by XJing on 16/1/18.
//  Copyright © 2016年 www.lanou3g.com 蓝鸥. All rights reserved.
//

#import "GifCell.h"

@implementation GifCell
- (void)dealloc
{
    [_web release];
    [_nameLable release];
    [_title release];
    [_str release];
    [_width release];
    [_heigth release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.web = [[UIWebView alloc]init];
        _web.backgroundColor = [UIColor redColor];
        _web.scalesPageToFit = YES;
        [self.contentView addSubview:_web];
        
        self.nameLable = [[UILabel alloc]init];
       // _nameLable.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:_nameLable];
        
        self.title = [[UILabel alloc]init];
        //_title.backgroundColor = [UIColor blueColor];
        [self.contentView addSubview:_title];
        
    }
    return self;
}
-(void)layoutSubviews
{
    [super layoutSubviews];

    _web.frame = CGRectMake(0, 5, 375,170);
    _web.center = self.contentView.center;
    _web.backgroundColor = [UIColor clearColor];
    //关闭webView滚动
//    _web.scrollView.bounces = NO;
//    _web.scrollView.showsHorizontalScrollIndicator = NO;
//    _web.scrollView.showsVerticalScrollIndicator = NO;
    _web.scrollView.scrollEnabled = NO;
    [_web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_str]]];
    _nameLable.frame = CGRectMake(5, _web.frame.origin.y + _web.frame.size.height, self.contentView.frame.size.width, 20);
    _nameLable.textColor = [UIColor grayColor];
    _nameLable.font = [UIFont systemFontOfSize:14];
    _title.frame = CGRectMake(5, _nameLable.frame.origin.y + _nameLable.frame.size.height + 5, self.contentView.frame.size.width, 40);
//    _title.textColor = [UIColor grayColor];
    _title.font = [UIFont systemFontOfSize:14];
    _title.numberOfLines = 0;
    
    
}
//设置高度自适应
+(NSArray *)heightWithh:(NSNumber *)h widthWithw:(NSNumber *)w
{
    double width = 0;
    double height = 0;
    if (w.doubleValue > 375) {
            width = 375;
            height = h.doubleValue * 375 / w.doubleValue;
    }else{
        width = w.doubleValue;
        height = h.doubleValue;
    }
    NSNumber *ww = [NSNumber numberWithDouble:width];
    NSNumber *hh = [NSNumber numberWithDouble:height];
    NSMutableArray *arr = [NSMutableArray array];
    [arr addObject:ww];
    [arr addObject:hh];
    return arr;
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
